﻿using System.Diagnostics;
using ShkSimulation.core.util;
using ShkSimulation.carsharing.impl.elements;

namespace ShkSimulation.carsharing.impl.util {
    public class VehicleBatteryComparator : IDuplicateComparer<Vehicle> {
        
        private static VehicleBatteryComparator instance;
        
        public static VehicleBatteryComparator Instance {
            get {
                if (instance == null) {
                    lock (typeof(VehicleBatteryComparator)) {
                        if (instance == null) {
                            instance = new VehicleBatteryComparator();
                        }
                    }
                }
                return instance;
            }
        }
        public int Compare(Vehicle x, Vehicle y) {
            Debug.Assert(x != null, nameof(x) + " != null");
            Debug.Assert(y != null, nameof(y) + " != null");
            if (x.Battery <= y.Battery) {
                return -1;
            } else {
                return 1;
            }
        }
    }
}
